<template>
	<view class="page">
		<searchDown :isDrop="true" @searchInput="searchInput" @getScreenItem="getScreenItem"></searchDown>
		<view class="list" v-if="list.length > 0">
			<doctorChatItem v-for="item in list" :key="item.id" :item="item" :fromPage="queryForm.consultWay">
			</doctorChatItem>
		</view>
		<view class="no_thing" v-else>
			<image class="placeholder" src="@/static/images/noting.png" mode="scaleToFill"></image>
		</view>
	</view>
</template>

<script>
	import {
		queryDoctorList
	} from '@/api/index.js'
	export default {
		data() {
			return {
				search: '',
				list: [],
				total: 0,
				queryForm: {
					pageNo: 1,
					pageSize: 10,
					consultWay: '',
				}
			}
		},
		onLoad(options) {
			let {
				consultWay
			} = options
			this.queryForm.consultWay = options.consultWay
			this.getDoctorList()
		},
		onReady() {
			console.log()
			uni.setNavigationBarTitle({
				title: this.queryForm.consultWay == 1 ? '普通门诊' : '专家门诊'
			});
		},
		methods: {
			getScreenItem(value) {
				this.resetQuery()
				if (value.parentId) {
					this.$set(this.queryForm, 'departId', value.id)
				} else if (value.departId) {
					this.$set(this.queryForm, 'proficientDiseases', value.id)
				}
				this.getDoctorList()
			},
			searchInput(value) {
				console.log(value)
			},
			resetQuery() {
				this.queryForm = {
					pageNo: 1,
					pageSize: 10,
					consultWay: this.queryForm.consultWay,
				}
			},
			getDoctorList() {
				queryDoctorList(this.queryForm).then((res) => {
					this.list = res.data.list
					this.total = res.data.total
				}).catch((err) => {
					console.log(err)
				})
			},
			gotoPage(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		padding: 0;

		.list {
			padding: 0 30rpx;
		}
	}
</style>